<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#include "../common/header.ftl">
    <script>
        $(function () {
            $('.showBtn').click(function () {
                //获取文章内容
                var id = $(this).data("tid");
                $.get("/travel/getContentById.do",{id:id},function (data) {
                    $(".modal-body").html(data.content);
                    $("#inputModal").modal("show");
                });
            });
            //修该状态
            $('.changeStateBtn').click(function () {
                var id = $(this).data("tid");
                var state = $(this).data("state");
                $.get("/travel/changeState.do",{id:id,state:state},function (data) {
                    if(data.success){
                        location.reload();
                    }
                });
            });
        });
    </script>
</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
            <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">待发布游记管理</h1>
                </div>
            </div>
        <#--高级查询--->
            <form class="form-inline" id="searchForm" action="/travel/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
            </form>
            <table class="table table-striped table-hover" >
                <tr>
                    <th>编号</th>
                    <th>标题</th>
                    <th>封面</th>
                    <th>作者</th>
                    <th>地区</th>
                    <th>状态</th>
                    <th></th>
                </tr>
                <#list pageInfo.list as entity>
                    <tr>
                       <td>${entity_index + 1}</td>
                       <td>${entity.title}</td>
                       <td>
                        <img src="${entity.coverUrl}" width="30px">
                        </td>
                        <td>${entity.author.nickName}</td>
                        <td>${(entity.place.name)!}</td>
                        <td>
                           <#if entity.state=-1>
                               拒绝
                               <#elseif entity.state=0>
                                草稿
                               <#elseif entity.state=1>
                                待发布
                               <#elseif entity.state=2>
                                已发布
                           </#if>
                        </td>
                        <td>
                            <a href="javascript:" class="btn btn-info btn-xs showBtn" data-tid="${entity.id}">
                                <span class="glyphicon glyphicon-pencil"></span> 查看内容
                            </a>
                            <a href="javascript:" class="btn btn-warning btn-xs changeStateBtn" data-state="2" data-tid="${entity.id}">
                                <span class="glyphicon glyphicon-leaf"></span> 发布
                            </a>
                            <a href="javascript:" class="btn btn-success btn-xs changeStateBtn" data-state="-1" data-tid="${entity.id}">
                                <span class="glyphicon glyphicon-plane"></span> 拒绝
                            </a>
                        </td>
                    </tr>
                </#list>
            </table>
            <#include "../common/page.ftl">
        </div>
    </div>
</div>
<#--查看内容-->
<div class="modal fade" id="inputModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">查看内容</h4>
            </div>
            <div class="modal-body">
            </div>
        </div>
    </div>
</div>
</body>
<style>
    #inputModal img{
        width: 100%;
    }

    #inputModal .modal-body{
        max-height: 600px;
        overflow-y: auto;
    }
</style>
</html>